#include"Server.hpp"
#include"Common.hpp"
#include"Dict.hpp"
#include<memory>



void UserError(std::string s)
{
    std::cerr<<s<<"port"<<std::endl;
}

//Server port
int main(int argc,char* argv[])
{

    if(argc!=2)
    {
        UserError(argv[0]);
        exit(ExitCode::USAGE_ERR);
    }

    uint16_t port=std::stoi(argv[1]);
    Dict d;
    d.LoadDict();

    std::unique_ptr<TcpServer> tcp=std::make_unique<TcpServer>(port,[&d](const std::string& message,InetAddr& peer){
        return d.Translate(message,peer);

    });

    //std::unique_ptr<TcpServer> tcp=std::make_unique<TcpServer>(port);




    tcp->Init();
    tcp->Run();




    return 0;
}